package com.le.tester.javaThink.fifth.chapter18_Str;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.StringReader;

/**
 * createTime：2021/8/17 9:53
 * description：简单的读取
 */
public class SimpleRead {
    public static BufferedReader in = new BufferedReader(new StringReader("Sir Robin of Camelot\n22 1.61803"));

    public static void main(String[] args) throws IOException {
        System.out.println("What is your name?");
        String line = in.readLine();
        System.out.println(line);
        System.out.println("How old are you?" + "What is your favorite double");

        System.out.println("(input: <age> <double>)");

        //注意有一个换行，readLine
        String numbers = in.readLine();
        System.out.println(numbers);
        String[] numArr = numbers.split(" ");

        int age = Integer.parseInt(numArr[0]);
        double favorite = Double.parseDouble(numArr[1]);
        System.out.format("Hi %s.%n", line);
        System.out.format("In 5 years you will be %d.%n", age + 5);
        System.out.format("My favorite double is %f.", favorite / 2);
    }
}
